#include <iostream>
using namespace std;

struct Point {
    int x;
    int y;
};

bool isIn(int l, int d, int r, int u, Point point) {
    return (point.x >= l && point.y >= d && point.x <= r && point.y <= u);
}

int main() {
    int n, k, t, l, d, r, u;
    cin >> n >> k >> t >> l >> d >> r >> u;
    Point point[n][t+1];
    for (int i = 0; i < n; i++)
        for (int j = 1; j <= t; j++)
            cin >> point[i][j].x >> point[i][j].y;
    int count1 = 0, count2 = 0;
    int count[n][t+1]={0};
    //通过上面这种方法对二维数组进行0初始化时，还需要对第一行进行循环设置为0，否则第一行数值是随机的。
    for (int i=0;i<t+1;i++){
        count[0][i]=0;
    }
    int sum[n][t+1]={0};
    for (int i=0;i<t+1;i++){
        sum[0][i]=0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= t; j++) {
            if (isIn(l, d, r, u, point[i][j])) {
                count[i][j] = 1;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= t; j++) {
            sum[i][j] = sum[i][j - 1] + count[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= t; j++) {
            if (count[i][j] == 1) {
                count1++;
                break;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = k; j <= t; j++) {
            if (sum[i][j] - sum[i][j - k] == k) {
                count2++;
                break;
            }
        }
    }
    cout << count1 << endl;
    cout << count2 << endl;
}


